package com.szqhyxj.youxiangju.biz.partnerHome.home.fragment.partnerequipment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.szqhyxj.youxiangju.BasePromptFragment;
import com.szqhyxj.youxiangju.R;
import com.szqhyxj.youxiangju.biz.merchantHome.my.MyPresenter;
import com.szqhyxj.youxiangju.biz.partnerHome.home.equipmentreceipt.EquipmentReceiptActivity;
import com.szqhyxj.youxiangju.biz.partnerHome.home.equipmentrepayment.EquipmentRepaymentActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by leung on 2018/10/31.
 */

public class PartnerEquipmentPaymentFragment extends BasePromptFragment implements PartnerEquipmentPaymentContract.View {

    Unbinder unbinder;

    PartnerEquipmentPaymentPresenter presenter;
    @BindView(R.id.repayment_num)
    TextView repaymentNum;
    @BindView(R.id.repayment_hundredOfMillionPeoples)
    TextView repaymentHundredOfMillionPeoples;
    @BindView(R.id.repayment_twentyMillionPeoples)
    TextView repaymentTwentyMillionPeoples;
    @BindView(R.id.repaymentperformance)
    LinearLayout repaymentperformance;
    @BindView(R.id.receipt_num)
    TextView receiptNum;
    @BindView(R.id.receipt_hundredOfMillionPeoples)
    TextView receiptHundredOfMillionPeoples;
    @BindView(R.id.receipt_twentyMillionPeoples)
    TextView receiptTwentyMillionPeoples;
    @BindView(R.id.collectionperformance)
    LinearLayout collectionperformance;
    @BindView(R.id.monthActivateRewards)
    TextView monthActivateRewards;
    @BindView(R.id.activationreward)
    LinearLayout activationreward;

    public static PartnerEquipmentPaymentFragment newInstance() {
        Bundle args = new Bundle();
        PartnerEquipmentPaymentFragment fragment = new PartnerEquipmentPaymentFragment();
        fragment.setArguments(args);
        return fragment;
    }


    @Override
    protected int getLayoutId() {
        return R.layout.fragment_equipment_payment;
    }
    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (isVisibleToUser) {
            if (presenter == null) {
                presenter = new PartnerEquipmentPaymentPresenter(this);
                presenter.init();
            }
        }
    }
    @Override
    protected void start(){
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);

        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }


    @Override
    public void showEquipmentPaymentInfo(ProxyEntity proxyEntity) {
        repaymentNum.setText(proxyEntity.getSumTradeAmt() + "");
        repaymentHundredOfMillionPeoples.setText(proxyEntity.getHundredOfMillionPeoples()+"");
        repaymentTwentyMillionPeoples.setText(proxyEntity.getTwentyMillionPeoples()+"");
    }

    @Override
    public void showEquipmentReceiptInfo(QuickEntity quickEntity) {
        receiptNum.setText(quickEntity.getSumTradeAmt() + "");
        receiptHundredOfMillionPeoples.setText(quickEntity.getHundredOfMillionPeoples() + "");
        receiptTwentyMillionPeoples.setText(quickEntity.getTwentyMillionPeoples() + "");
    }

    @Override
    public void showActivationReward(String monthActivateReward) {
        monthActivateRewards.setText(monthActivateReward + "");
    }

    @Override
    public void navToPaymentDetails() {
        EquipmentRepaymentActivity.start(getActivity());

    }

    @Override
    public void navToReceiptDetails() {
        EquipmentReceiptActivity.start(getActivity());

    }

    @Override
    public void navToRewardDetails() {


    }

    @OnClick({R.id.repaymentperformance, R.id.collectionperformance, R.id.activationreward})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.repaymentperformance:
                presenter.setPaymentDetails();
                break;
            case R.id.collectionperformance:
                presenter.setReceiptDetails();
                break;
            case R.id.activationreward:
                presenter.setRewardDetails();
                break;
        }
    }
}